home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 8 / develop 8 code / TValidText / Test.r < prev    next >
Encoding:
Text File  |  1991-10-09  |  11.8 KB  |  696 lines  |  [TEXT/MPS ]

  1. // Test.r
  2.  
  3. // • Auto-Include the requirements for this source
  4. #ifndef __TYPES.R__
  5. #include "Types.r"
  6. #endif
  7.  
  8. #ifndef __MacAppTypes__
  9. #include "MacAppTypes.r"
  10. #endif
  11.  
  12. #ifndef __ViewTypes__
  13. #include "ViewTypes.r"
  14. #endif
  15.  
  16. #if qDebug
  17. include "Debug.rsrc";
  18. #endif
  19. include "MacApp.rsrc";
  20. include "Dialog.rsrc";
  21. include "Printing.rsrc";
  22. include "SplashPict.rsrc";                // Picture displayed in the Splash dialog
  23.  
  24. // Grab lots of resources from Apple's defaults, except those noted below, which
  25. // were removed from a copy of Apple's 'Defaults.rsrc' file
  26. include "MacAppDefaults.rsrc";
  27.  
  28. include $$Shell("ObjApp")"Test" 'CODE';
  29.  
  30. // new stuff
  31. #define cEnterDateTime        3000        // Command to enter new date/time
  32. #define mDateTime               4        // DateTime menu
  33. #define    kDialogWindowID        2001        // dialog window
  34. #define    kDialogViewID        2002        // dialog view
  35. #define kSplash                3001        // splash dialog
  36.  
  37. // Only our DateTime menu is defined here; all other menus are taken from MacApp
  38. resource 'cmnu' (mDateTime) {
  39.     mDateTime,
  40.     textMenuProc,
  41.     0x00000001,
  42.     enabled,
  43.     "DateTime",
  44.     {
  45.     /* [1] */
  46.     "Enter Date or Time…",
  47.     noIcon, "E", noMark, plain, cEnterDateTime;
  48.     }
  49. };
  50.  
  51. // this resource replaces one deleted from the MacAppDefaults.rsrc
  52. resource 'MBAR' (kMBarDisplayed) {
  53.     {mApple; mFile; mEdit; mDateTime}
  54. };
  55.  
  56.  
  57. // popup menus
  58. resource 'MENU' (2001) {
  59.     2001,
  60.     textMenuProc,
  61.     0x0000000F,
  62.     enabled,
  63.     "Object: ",
  64.      {    /* array: 4 elements */
  65.         /* [1] */
  66.         "shortDate",                     noIcon, noKey, noMark, plain;
  67.         /* [2] */
  68.         "longDate",                     noIcon, noKey, noMark, plain;
  69.         /* [3] */
  70.         "abbrevDate",                     noIcon, noKey, noMark, plain;
  71.         /* [4] */
  72.         "defDateForm",                     noIcon, noKey, noMark, plain
  73.     }
  74. };
  75.  
  76. resource 'MENU' (2002) {
  77.     2002,
  78.     textMenuProc,
  79.     0x00000007,
  80.     enabled,
  81.     "Global: ",
  82.      {    /* array: 4 elements */
  83.         /* [1] */
  84.         "shortDate",                     noIcon, noKey, noMark, plain;
  85.         /* [2] */
  86.         "longDate",                     noIcon, noKey, noMark, plain;
  87.         /* [3] */
  88.         "abbrevDate",                     noIcon, noKey, noMark, plain
  89.     }
  90. };
  91.  
  92.  
  93. /*********************************************************************************
  94.     The following resources define the application's "about…" box.  The
  95.     corresponding resources were delected from MacAppDefaults.rsrc.
  96. *********************************************************************************/
  97.  
  98. resource 'ALRT' (phAboutApp, purgeable) {
  99.     {40, 40, 238, 438},
  100.     phAboutApp,
  101.     {    /* array: 4 elements */
  102.         /* [1] */
  103.         OK, visible, silent,
  104.         /* [2] */
  105.         OK, visible, silent,
  106.         /* [3] */
  107.         OK, visible, silent,
  108.         /* [4] */
  109.         OK, visible, silent
  110.     }
  111. };
  112.  
  113. resource 'DITL' (phAboutApp, "AboutBox", purgeable) {
  114.     {    /* array DITLarray: 2 elements */
  115.         /* [1] */
  116.         {164, 224, 184, 284},
  117.         Button {
  118.             enabled,
  119.             "OK"
  120.         },
  121.         /* [2] */
  122.         {10, 10, 188, 364},
  123.         Picture {
  124.             disabled,
  125.             kSplash
  126.         }
  127.     }
  128. };
  129.  
  130.  
  131. /*********************************************************************************
  132.     The following resources define the Date/Time definition dialog.  It must use
  133.     standard resources (ie., not 'view' resources) because it is displayed before
  134.     MacApp has been initialized.
  135.     
  136.     The 'PICT' resource is included froma resource file.  Displaying a bunch of
  137.     derezzed hex doesn't tell anybody anything, anyway.
  138. *********************************************************************************/
  139.  
  140. resource 'DLOG' (kSplash, "Splash", purgeable, preload) {
  141.     {40, 40, 238, 438},
  142.     dBoxProc,
  143.     visible,
  144.     noGoAway,
  145.     0x0,
  146.     kSplash,
  147.     ""
  148. };
  149.  
  150. resource 'DITL' (kSplash, "Splash", purgeable, preload) {
  151.     {    /* array DITLarray: 1 elements */
  152.         /* [1] */
  153.         {10, 10, 188, 364},
  154.         Picture {
  155.             disabled,
  156.             kSplash
  157.         }
  158.     }
  159. };
  160.  
  161.  
  162. /*********************************************************************************
  163. The following 'view' resources define the Date/Time definition dialog.
  164. *********************************************************************************/
  165.  
  166. resource 'view' (kDialogWindowID, "DateTimeTest Window", purgeable) {
  167.     {    /* array viewArray: 11 elements */
  168.         /* [1] */
  169.         root, 'wind',
  170.         {    /* array: 1 elements */
  171.             /* [1] */
  172.             50, 40
  173.         },
  174.         {    /* array: 1 elements */
  175.             /* [1] */
  176.             200, 410
  177.         }, sizeVariable, sizeVariable, shown, enabled,
  178.         Window {
  179.             "TWindow",
  180.             dBoxProc,
  181.             noGoAwayBox,
  182.             notResizable,
  183.             modal,
  184.             ignoreFirstClick,
  185.             freeOnClosing,
  186.             disposeOnFree,
  187.             closesDocument,
  188.             openWithDocument,
  189.             dontAdaptToScreen,
  190.             dontStagger,
  191.             dontForceOnScreen,
  192.             center,
  193.             'DLOG',
  194.             "<<<>>>"
  195.         },
  196.         /* [2] */
  197.         'wind', IncludeViews {kDialogViewID}
  198.     }
  199. };
  200.         
  201. resource 'view' (kDialogViewID, "DateTimeTest Dialog", purgeable) {
  202.     {    /* array viewArray: 11 elements */
  203.         /* [1] */
  204.         root, 'DLOG',
  205.         {    /* array: 1 elements */
  206.             /* [1] */
  207.             0, 0
  208.         },
  209.         {    /* array: 1 elements */
  210.             /* [1] */
  211.             200, 410
  212.         }, sizeVariable, sizeVariable, shown, enabled,
  213.         DialogView {
  214.             "TTestDialog",
  215.             '_OK_',
  216.             'CNCL'
  217.         },
  218.         /* [3] */
  219.         'DLOG', 'help',
  220.         {    /* array: 1 elements */
  221.             /* [1] */
  222.             10, 10
  223.         },
  224.         {    /* array: 1 elements */
  225.             /* [1] */
  226.             40, 385
  227.         }, sizeFixed, sizeFixed, shown, disabled,
  228.         StaticText {
  229.             "TStaticText",
  230.             0b0,
  231.             {1, 1},
  232.             sizeable,
  233.             notDimmed,
  234.             notHilited,
  235.             doesntDismiss,
  236.             {0, 0, 0, 0},
  237.             plain,
  238.             9,
  239.             {    /* array: 3 elements */
  240.                 /* [1] */
  241.                 0x0,
  242.                 /* [2] */
  243.                 0x0,
  244.                 /* [3] */
  245.                 0x0
  246.             },
  247.             "A",
  248.             justLeft,
  249.             "Enter a date into the “Date” item, and a "
  250.             "time into the “Time” item.  Use the other "
  251.             "controls to change the appearance and "
  252.             "validation of the date and time."
  253.         },
  254.         /* [4] */
  255.         'DLOG', '_OK_',
  256.         {    /* array: 1 elements */
  257.             /* [1] */
  258.             145, 320
  259.         },
  260.         {    /* array: 1 elements */
  261.             /* [1] */
  262.             28, 80
  263.         }, sizeFixed, sizeFixed, shown, enabled,
  264.         Button {
  265.             "TButton",
  266.             0b1000000,
  267.             {3, 3},
  268.             sizeable,
  269.             notDimmed,
  270.             notHilited,
  271.             dismisses,
  272.             {4, 4, 4, 4},
  273.             plain,
  274.             0,
  275.             {    /* array: 3 elements */
  276.                 /* [1] */
  277.                 0x0,
  278.                 /* [2] */
  279.                 0x0,
  280.                 /* [3] */
  281.                 0x0
  282.             },
  283.             "",
  284.             "OK"
  285.         },
  286.         /* [5] */
  287.         'DLOG', 'CNCL',
  288.         {    /* array: 1 elements */
  289.             /* [1] */
  290.             115, 323
  291.         },
  292.         {    /* array: 1 elements */
  293.             /* [1] */
  294.             20, 74
  295.         }, sizeFixed, sizeFixed, shown, enabled,
  296.         Button {
  297.             "TButton",
  298.             0b0,
  299.             {1, 1},
  300.             sizeable,
  301.             notDimmed,
  302.             notHilited,
  303.             dismisses,
  304.             {0, 0, 0, 0},
  305.             plain,
  306.             0,
  307.             {    /* array: 3 elements */
  308.                 /* [1] */
  309.                 0x0,
  310.                 /* [2] */
  311.                 0x0,
  312.                 /* [3] */
  313.                 0x0
  314.             },
  315.             "",
  316.             "Cancel"
  317.         },
  318.         /* [6] */
  319.         'DLOG', 'date',
  320.         {    /* array: 1 elements */
  321.             /* [1] */
  322.             95, 10
  323.         },
  324.         {    /* array: 1 elements */
  325.             /* [1] */
  326.             20, 50
  327.         }, sizeFixed, sizeFixed, shown, disabled,
  328.         StaticText {
  329.             "TStaticText",
  330.             0b0,
  331.             {1, 1},
  332.             sizeable,
  333.             notDimmed,
  334.             notHilited,
  335.             doesntDismiss,
  336.             {0, 0, 0, 0},
  337.             plain,
  338.             0,
  339.             {    /* array: 3 elements */
  340.                 /* [1] */
  341.                 0x0,
  342.                 /* [2] */
  343.                 0x0,
  344.                 /* [3] */
  345.                 0x0
  346.             },
  347.             "",
  348.             justLeft,
  349.             "Date:"
  350.         },
  351.         /* [7] */
  352.         'DLOG', 'time',
  353.         {    /* array: 1 elements */
  354.             /* [1] */
  355.             125, 10
  356.         },
  357.         {    /* array: 1 elements */
  358.             /* [1] */
  359.             20, 50
  360.         }, sizeFixed, sizeFixed, shown, disabled,
  361.         StaticText {
  362.             "TStaticText",
  363.             0b0,
  364.             {1, 1},
  365.             sizeable,
  366.             notDimmed,
  367.             notHilited,
  368.             doesntDismiss,
  369.             {0, 0, 0, 0},
  370.             plain,
  371.             0,
  372.             {    /* array: 3 elements */
  373.                 /* [1] */
  374.                 0x0,
  375.                 /* [2] */
  376.                 0x0,
  377.                 /* [3] */
  378.                 0x0
  379.             },
  380.             "",
  381.             justLeft,
  382.             "Time:"
  383.         },
  384.         'DLOG', 'DATE',
  385.         {    /* array: 1 elements */
  386.             /* [1] */
  387.             92, 60
  388.         },
  389.         {    /* array: 1 elements */
  390.             /* [1] */
  391.             20, 235
  392.         }, sizeFixed, sizeFixed, shown, enabled,
  393.         DateEditText {
  394.             "TDateEditText",
  395.             0b1111,
  396.             {1, 1},
  397.             sizeable,
  398.             notDimmed,
  399.             notHilited,
  400.             doesntDismiss,
  401.             {2, 2, 2, 2},
  402.             plain,
  403.             0,
  404.             {    /* array: 3 elements */
  405.                 /* [1] */
  406.                 0x0,
  407.                 /* [2] */
  408.                 0x0,
  409.                 /* [3] */
  410.                 0x0
  411.             },
  412.             "",
  413.             justLeft,
  414.             "",
  415.             60,
  416.             0b11110000000000000000000100000000,
  417.             laxValidation,                    // ignore non-fatal validation errors
  418.             notRequired,                    // an empty string is OK
  419.             kInvalidDateTimeAlert,            // use the date-time error alert
  420.             longDate                        // use long date format
  421.         },
  422.         /* [11] */
  423.         'DLOG', 'TIME',
  424.         {    /* array: 1 elements */
  425.             /* [1] */
  426.             122, 60
  427.         },
  428.         {    /* array: 1 elements */
  429.             /* [1] */
  430.             20, 235
  431.         }, sizeVariable, sizeVariable, shown, enabled,
  432.         TimeEditText {
  433.             "TTimeEditText",
  434.             0b1111,
  435.             {1, 1},
  436.             sizeable,
  437.             notDimmed,
  438.             notHilited,
  439.             doesntDismiss,
  440.             {2, 2, 2, 2},
  441.             plain,
  442.             0,
  443.             {    /* array: 3 elements */
  444.                 /* [1] */
  445.                 0x0,
  446.                 /* [2] */
  447.                 0x0,
  448.                 /* [3] */
  449.                 0x0
  450.             },
  451.             "",
  452.             justLeft,
  453.             "",
  454.             60,
  455.             0b11110000000000000000000100000000,
  456.             laxValidation,                    // ignore non-fatal validation errors
  457.             notRequired,                    // an empty string is OK
  458.             kInvalidDateTimeAlert,            // use the date-time error alert
  459.             dontWantSeconds                    // don't show seconds
  460.         },
  461.         /* [7] */
  462.         'DLOG', 'PClu',
  463.         {    /* array: 1 elements */
  464.             /* [1] */
  465.             50, 10
  466.         },
  467.         {    /* array: 1 elements */
  468.             /* [1] */
  469.             40, 290
  470.         }, sizeFixed, sizeFixed, shown, disabled,
  471.         Cluster {
  472.             "TCluster",
  473.             0b0,
  474.             {1, 1},
  475.             sizeable,
  476.             notDimmed,
  477.             notHilited,
  478.             doesntDismiss,
  479.             {0, 0, 0, 0},
  480.             plain,
  481.             0,
  482.             {    /* array: 3 elements */
  483.                 /* [1] */
  484.                 0x0,
  485.                 /* [2] */
  486.                 0x0,
  487.                 /* [3] */
  488.                 0x0
  489.             },
  490.             "",
  491.             "Date Forms"
  492.         },
  493.         /* [8] */
  494.         'PClu', 'pDAT',
  495.         {    /* array: 1 elements */
  496.             /* [1] */
  497.             15, 5
  498.         },
  499.         {    /* array: 1 elements */
  500.             /* [1] */
  501.             20, 135
  502.         }, sizeVariable, sizeVariable, shown, enabled,
  503.         Popup {
  504.             "TFixedPopup",
  505.             0b0,
  506.             {1, 1},
  507.             sizeable,
  508.             notDimmed,
  509.             notHilited,
  510.             doesntDismiss,
  511.             {0, 0, 0, 0},
  512.             plain,
  513.             0,
  514.             {    /* array: 3 elements */
  515.                 /* [1] */
  516.                 0x0,
  517.                 /* [2] */
  518.                 0x0,
  519.                 /* [3] */
  520.                 0x0
  521.             },
  522.             "",
  523.             2001,
  524.             2,            // longDate (match dateForm field in 'DATE' view, above)
  525.             50
  526.         },
  527.         /* [9] */
  528.         'PClu', 'pGLO',
  529.         {    /* array: 1 elements */
  530.             /* [1] */
  531.             15, 145
  532.         },
  533.         {    /* array: 1 elements */
  534.             /* [1] */
  535.             20, 135
  536.         }, sizeVariable, sizeVariable, shown, enabled,
  537.         Popup {
  538.             "TFixedPopup",
  539.             0b0,
  540.             {1, 1},
  541.             sizeable,
  542.             notDimmed,
  543.             notHilited,
  544.             doesntDismiss,
  545.             {0, 0, 0, 0},
  546.             plain,
  547.             0,
  548.             {    /* array: 3 elements */
  549.                 /* [1] */
  550.                 0x0,
  551.                 /* [2] */
  552.                 0x0,
  553.                 /* [3] */
  554.                 0x0
  555.             },
  556.             "",
  557.             2002,
  558.             1,        // shortDate (match defDateForm in ITestApplication)
  559.             50
  560.         },
  561.         /* [8] */
  562.         'DLOG', 'HOUR',
  563.         {    /* array: 1 elements */
  564.             /* [1] */
  565.             150, 10
  566.         },
  567.         {    /* array: 1 elements */
  568.             /* [1] */
  569.             20, 250
  570.         }, sizeFixed, sizeFixed, shown, enabled,
  571.         CheckBox {
  572.             "TCheckBox",
  573.             0b0,
  574.             {1, 1},
  575.             sizeable,
  576.             notDimmed,
  577.             notHilited,
  578.             doesntDismiss,
  579.             {0, 0, 0, 0},
  580.             plain,
  581.             0,
  582.             {    /* array: 3 elements */
  583.                 /* [1] */
  584.                 0x0,
  585.                 /* [2] */
  586.                 0x0,
  587.                 /* [3] */
  588.                 0x0
  589.             },
  590.             "",
  591.             off,
  592.             "use a 24-hour clock (military time)"
  593.         },
  594.         /* [8] */
  595.         'DLOG', 'SECS',
  596.         {    /* array: 1 elements */
  597.             /* [1] */
  598.             170, 10
  599.         },
  600.         {    /* array: 1 elements */
  601.             /* [1] */
  602.             20, 250
  603.         }, sizeFixed, sizeFixed, shown, enabled,
  604.         CheckBox {
  605.             "TCheckBox",
  606.             0b0,
  607.             {1, 1},
  608.             sizeable,
  609.             notDimmed,
  610.             notHilited,
  611.             doesntDismiss,
  612.             {0, 0, 0, 0},
  613.             plain,
  614.             0,
  615.             {    /* array: 3 elements */
  616.                 /* [1] */
  617.                 0x0,
  618.                 /* [2] */
  619.                 0x0,
  620.                 /* [3] */
  621.                 0x0
  622.             },
  623.             "",
  624.             off,
  625.             "display seconds"
  626.         },
  627.         /* [9] */
  628.         'DLOG', 'Vlid',
  629.         {    /* array: 1 elements */
  630.             /* [1] */
  631.             40, 315
  632.         },
  633.         {    /* array: 1 elements */
  634.             /* [1] */
  635.             30, 90
  636.         }, sizeFixed, sizeFixed, shown, enabled,
  637.         CheckBox {
  638.             "TCheckBox",
  639.             0b0,
  640.             {1, 1},
  641.             sizeable,
  642.             notDimmed,
  643.             notHilited,
  644.             doesntDismiss,
  645.             {0, 0, 0, 0},
  646.             plain,
  647.             0,
  648.             {    /* array: 3 elements */
  649.                 /* [1] */
  650.                 0x0,
  651.                 /* [2] */
  652.                 0x0,
  653.                 /* [3] */
  654.                 0x0
  655.             },
  656.             "",
  657.             off,
  658.             "strict\nvalidation"
  659.         },
  660.         /* [9] */
  661.         'DLOG', 'rqur',
  662.         {    /* array: 1 elements */
  663.             /* [1] */
  664.             75, 315
  665.         },
  666.         {    /* array: 1 elements */
  667.             /* [1] */
  668.             30, 90
  669.         }, sizeFixed, sizeFixed, shown, enabled,
  670.         CheckBox {
  671.             "TCheckBox",
  672.             0b0,
  673.             {1, 1},
  674.             sizeable,
  675.             notDimmed,
  676.             notHilited,
  677.             doesntDismiss,
  678.             {0, 0, 0, 0},
  679.             plain,
  680.             0,
  681.             {    /* array: 3 elements */
  682.                 /* [1] */
  683.                 0x0,
  684.                 /* [2] */
  685.                 0x0,
  686.                 /* [3] */
  687.                 0x0
  688.             },
  689.             "",
  690.             off,
  691.             "must enter\nvalue"
  692.         }
  693.     }
  694. };
  695.  
  696.